#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int n = 0, j = 0, f = 1, s = 0;
    char a[20] = { 0 };
    int qz[17] = { 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 };
    char m[17] = { '1','0','X','9','8','7','6','5','4','3','2' };
    scanf("%d", &n);
    int i = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%s", a);
        s = 0;
        for (j = 0; j < 18; j++)
        {
            s += (a[j] - '0') * qz[j];
        }
        s %= 11;
        if (m[s] != a[17])
        {
            f = 0;
            printf("%s\n", a);
        }
    }
    if (f == 1)
    {
        printf("All passed");
    }
return 0;
}